/**
 * @description 适配对象
 */
import { IUserBaseInfo, IUserHomeInfo, IUserInfo, IUserOfficeInfo } from "./AdaptClass";

interface IOuterBaseInfo {
  getUserBaseInfo(): IUserBaseInfo
}
interface IOuterUserOfficeInfo {
  getUserOfficeInfo(): IUserOfficeInfo
}
interface IOuterUserHomeInfo {
  getUserHomeInfo(): IUserHomeInfo
}

class OuterBaseInfo implements IOuterBaseInfo {
  getUserBaseInfo(): IUserBaseInfo {
    return {
      userName: 'outUserName',
      mobileNumber: 'outMobileNumber'
    }
  }
}

class OuterUserOfficeInfo implements IOuterUserOfficeInfo {
  getUserOfficeInfo(): IUserOfficeInfo {
    return {
      officeTelNumber: 'outOfficeTelNumber',
      jobPosition: 'outJobPosition'
    }
  }
}

class OuterUserHomeInfo implements IOuterUserHomeInfo {
  getUserHomeInfo(): IUserHomeInfo {
    return {
      homeTelNumber: 'outHomeTelNumber',
      homeAddress: 'outHomeAddress'
    }
  }
}
/**
 * @description 适配器角色
 */
class OuterUserInfoObj implements IUserInfo {
  _outerBaseInfo: OuterBaseInfo = null;
  _outerUserOfficeInfo: OuterUserOfficeInfo = null;
  _outerUserHomeInfo: OuterUserHomeInfo = null;
  constructor(outerBaseInfo: OuterBaseInfo, outerUserOfficeInfo: OuterUserOfficeInfo, outerUserHomeInfo: OuterUserHomeInfo,) {
    this._outerBaseInfo = outerBaseInfo
    this._outerUserOfficeInfo = outerUserOfficeInfo
    this._outerUserHomeInfo = outerUserHomeInfo
  }
  getUserName(): string {
    return this._outerBaseInfo.getUserBaseInfo().userName
  }
  getHomeAddress(): string {
    return this._outerUserHomeInfo.getUserHomeInfo().homeAddress
  }
  getMobileNumber(): string {
    return this._outerBaseInfo.getUserBaseInfo().mobileNumber
  }
  getOfficeTelNumber(): string {
    return this._outerUserOfficeInfo.getUserOfficeInfo().officeTelNumber
  }
  getJobPosition(): string {
    return this._outerUserOfficeInfo.getUserOfficeInfo().jobPosition
  }
  getHomeTelNumber(): string {
    return this._outerUserHomeInfo.getUserHomeInfo().homeTelNumber
  }
}

function main() {
  const _outerBaseInfo = new OuterBaseInfo()
  const _outerUserHomeInfo = new OuterUserHomeInfo()
  const _outerUserOfficeInfo = new OuterUserOfficeInfo()
  const _outerOuterUserInfo = new OuterUserInfoObj(_outerBaseInfo, _outerUserOfficeInfo, _outerUserHomeInfo)
  console.log(_outerOuterUserInfo.getJobPosition())
}

main()